<!--
 * @Description: 评价列表
 * @Autor: dyx
 * @Date: 2023-05-26 16:16:44
 * @LastEditTime: 2023-05-26 17:22:55
-->
<template>
  <div class="list">
    <JADP-table v-loading="listLoading" :data="list" height="600">
      <el-table-column label="班级名称" prop="classname" />
      <el-table-column
        label="课件名称"
        prop="coursewarename"
        v-if="categoretype == 3 || categoretype == 4"
      />
      <el-table-column
        label="讲师姓名"
        prop="teachername"
        v-if="categoretype == 4"
      />
      <el-table-column label="学员姓名" prop="studentname" />
      <el-table-column label="操作" fixed="right" width="140">
        <template #default="{ row }">
          <el-button type="text" @click="view(row.id)">查看 </el-button>
        </template>
      </el-table-column>
    </JADP-table>
    <pagination
      :total="total"
      :page.sync="listQuery.currentPage"
      :limit.sync="listQuery.pageSize"
      @pagination="initData"
    />
    <Form v-if="formVisible" ref="Form" :categoretype="categoretype" />
  </div>
</template>
<script>
import { getEvaluationList } from "@/api/zazx/evaluation.js";
import Form from "./form.vue";
export default {
  components: {
    Form
  },
  props: {
    categoretype: {
      type: Number,
      default: 1
    },
    classid: {
      type: String,
      default: 0
    }
  },
  data() {
    return {
      listLoading: false,
      formVisible: false,
      list: [],
      total: 0,
      query: {
        studentname: undefined
      },
      listQuery: {
        currentPage: 1,
        pageSize: 20,
        sort: "desc",
        sidx: "creatortime"
      },
      categoretype: "",
      classid: ""
    };
  },
  mounted() {
    // setTimeout(() => {
    //   this.initData();
    // });
  },
  methods: {
    async initData() {
      this.listLoading = true;
      let query = {
        ...this.listQuery,
        ...this.query,
        classid: this.classid,
        categoretype: this.categoretype // 1-培训班  2-课程 3-课件  4-讲师
      };
      const { data } = await getEvaluationList(query);
      this.list = data.list;
      this.total = data.pagination.total;
      this.listLoading = false;
    },

    view(id) {
      this.formVisible = true;
      this.$nextTick(() => {
        this.$refs.Form.initData(id);
      });
    }
  }
};
</script>
<style scoped lang="scss"></style>
